﻿using MediatR;
using T.Contract.API.Application.Command.ContractCommand;
using T.Contract.Repository.Interface;

namespace T.Contract.API.Application.CommandHandlers.ContractHandler
{
    /// <summary>
    /// 定义路线
    /// </summary>
    public class ContractLineAddCommandHandler : IRequestHandler<ContractLineAddCommand, int>
    {
        protected readonly IContractRepository contractRepository;

        public ContractLineAddCommandHandler(IContractRepository contractRepository)
        {
            this.contractRepository = contractRepository;
        }
        public async Task<int> Handle(ContractLineAddCommand request, CancellationToken cancellationToken)
        {
            var upLine = await contractRepository.GetModelAsync(request.ContractId);
            upLine.line = request.line;
            upLine.longitude= request.longitude;
            upLine.latitude= request.latitude;
            return await contractRepository.UpdateAsync(upLine);

        }
    }
}
